<?php


namespace App\Http\Controllers\applets\api;


use App\Http\Controllers\admin\service\AccountCenterService;
use App\Http\Controllers\admin\validate\AccountCenter;
use App\Http\Controllers\applets\service\UserInfoService;
use App\Http\Controllers\applets\validate\UserInfo;
use App\Http\Controllers\utils\ToolUtil;
use Illuminate\Http\Request;

class UserInfoApi
{

    public function getLoginCode(Request $request)
    {
        $param = $request->all();
        $data = UserInfo::getLoginCode($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::getLoginCode($param);
    }

    public function codeLogin(Request $request)
    {
        $param = $request->all();
        $data = UserInfo::codeLogin($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::codeLogin($param);
    }

    public function login(Request $request)
    {
        $param = $request->all();
        $data = AccountCenter::login($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::login($param);
    }

    public function register(Request $request){
        $param = $request->all();
        $data = UserInfo::register($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::register($param);
    }

    public function getUserInfo(Request $request){
        $param = $request->all();
        $data = UserInfo::getUserInfo($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::getUserInfo($param);
    }

    public function editMobile(Request $request){
        $param = $request->all();
        $data = UserInfo::editMobile($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::editMobile($param);
    }

    public function getSms(Request $request){
        $param = $request->all();
        $data = AccountCenter::getCode($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return AccountCenterService::smsAli($param);
    }

    public function editPassword(Request $request){
        $param = $request->all();
        $data = UserInfo::editPassword($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::editPassword($param);
    }

    public function getParentSn(Request $request){
        $param = $request->all();
        $data = UserInfo::getParentSn($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::getParentSn($param);
    }

    public function getSnInfo(Request $request){
        $param = $request->all();
        $data = UserInfo::getSnInfo($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::getSnInfo($param);
    }

    public function getClassInfo(Request $request){
        $param = $request->all();
        $data = UserInfo::getClassInfo($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::getClassInfo($param);
    }

    public function addClass(Request $request){
        $param = $request->all();
        $data = UserInfo::addClass($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::addClass($param);
    }

    public function getClassSnInfo(Request $request){
        $param = $request->all();
        $data = UserInfo::getClassSnInfo($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::getClassSnInfo($param);
    }

    public function queryIdAdmin(Request $request){
        $param = $request->all();
        $data = UserInfo::queryIdAdmin($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::queryIdAdmin($param);
    }

    public function updateParentSn(Request $request){
        $param = $request->all();
        $data = UserInfo::updateParentSn($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::updateParentSn($param);
    }

    public function updateAvatar(Request $request){
        $param = $request->all();
        $data = UserInfo::updateAvatar($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::updateAvatar($param);
    }

    public function querySnInfo(Request $request){
        $param = $request->all();
        $data = UserInfo::querySnInfo($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::querySnInfo($param);
    }

    public function retrievePassword(Request $request){
        $param = $request->all();
        $data = UserInfo::retrievePassword($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return UserInfoService::retrievePassword($param);
    }
}

